package me.pcqpcq.android.tvlauncher.adapter;

import me.pcqpcq.android.tvlauncher.R;
import android.content.Context;
import android.support.v4.view.PagerAdapter;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;

public class WheelGroupAdapter extends PagerAdapter {
	
	private Context mContext;

    private int[] wheels = new int[]{
            R.drawable.wheel1,
            R.drawable.wheel2,
            R.drawable.wheel3,
            R.drawable.wheel4,
            R.drawable.wheel5,
            R.drawable.wheel6,
    };
	
	public WheelGroupAdapter(Context context) {
		this.mContext = context;
	}

	@Override
	public int getCount() {
		return Integer.MAX_VALUE;
	}
	
	@Override
	public Object instantiateItem(ViewGroup container, int position) {
		//TODO: Test
		ImageView imvItem = new ImageView(mContext);
		imvItem.setImageResource(wheels[position % wheels.length]);
		container.addView(imvItem);
		return imvItem;
	}

	@Override
	public void destroyItem(ViewGroup container, int position, Object object) {
		container.removeView((View) object);
	}
	
	@Override
	public boolean isViewFromObject(View arg0, Object arg1) {
		return arg0 == arg1;
	}

}
